{block name=table-attendance}
{if $enrolments}
	<!-- Nav tabs -->
		<ul class="nav nav-tabs" role="tablist">
			<li class="active"><a href="#roll"  role="tab" data-toggle="tab">Roll</a></li>
			<li><a href="#walkin" role="tab" data-toggle="tab">Walk in</a></li>
		</ul>

		<!-- Tab panes -->
		<div class="tab-content">
			<div class="tab-pane active" id="roll">
				<form class="form-horizontal" id="SaveAttendance-form" role="form" accept-charset="UTF-8" action="" method="post" >
					<input type="hidden" value="SaveAttendace" name="action"/> 
					<input type="hidden" value="/admin/includes/processes/processes-enrolment.php" name="url"/> 
					<input type="hidden" name="formToken" value="{$token}" />
			
					<table class="table table-striped">
						<thead>
							<th>姓名</th>
							<th>状态</th>
							<th>Attended</th>
						</thead>
						<tbody>
							{foreach $enrolments as $enrol}
									<tr{if $enrol.enrolment_published neq 1} class="text-deleted"{/if}>
										<td>{$enrol.student_name} {$enrol.student_surname}</td>
										<td>{$enrol.type_name}</td>
										<td>
											<input type="hidden" name="attendace[{$enrol.enrolment_id}]" class="value" value="{$enrol.enrolment_attended}">
											<input type="checkbox" name="checks[{$enrol.enrolment_id}]" {if $enrol.enrolment_attended}checked="checked"{/if} class="chk-students" onchange="if($(this).is(':checked')){ $(this).parent().children('.value').val('1') }else{ $(this).parent().children('.value').val('0') }">
										</td>
									</tr>
								{/foreach}
						</tbody>
					</table>
					<div class="text-right">
						<a href="javascript:void(0);" onClick="changeChkboxes('.chk-students');" class="btn btn-info btn-xs">Select/Deselect All</a>
					</div>
					<div class="text-center">
						<button type="submit" class="btn btn-default">Save attendance roll</button>
					</div>
				</form>
			</div>
			
			<div class="tab-pane" id="walkin">
				<form class="form-horizontal form" id="WalkIn-form" role="form" accept-charset="UTF-8" action="" method="post" >
					<input type="hidden" value="WalkInForm" name="action"/> 
					<input type="hidden" value="/admin/includes/processes/processes-enrolment.php" name="url"/>
					<input type="hidden" name="walkin_term_object_id" value="{$term_object_id}" />
					<input type="hidden" name="walkin_class_object_id" value="{$class_object_id}" />
					<input type="hidden" name="term_name" value="{$term_name}" />
					<input type="hidden" name="class_name" value="{$class_name}" />
					<input type="hidden" name="walkin_week" value="{$week}" /> 
					<input type="hidden" name="formToken" value="{$token}" />
			
					<div class="row form-group">
						<label for="walkin_user_gname" class="col-sm-3 control-label">Guardian's first name*</label>
						<div class="col-sm-6">
							<input type="text" class="form-control clear-saved" name="walkin_user_gname" value="" id="walkin_user_gname" required/> 
						</div>
					</div>
					<div class="row form-group">
						<label for="walkin_user_surname" class="col-sm-3 control-label">Guardian's last name*</label>
						<div class="col-sm-6">
							<input type="text" class="form-control clear-saved" name="walkin_user_surname" value="" id="walkin_user_surname" required/> 
						</div>
					</div>
					<div class="row form-group">
						<label for="walkin_student_name" class="col-sm-3 control-label">Child's first name*</label>
						<div class="col-sm-6">
							<input type="text" class="form-control clear-saved" name="walkin_student_name" value="" id="walkin_student_name" required/> 
						</div>
					</div>
					<div class="row form-group">
						<label for="walkin_student_surname" class="col-sm-3 control-label">Child's last name*</label>
						<div class="col-sm-6">
							<input type="text" class="form-control clear-saved" name="walkin_student_surname" value="" id="walkin_student_surname" required/> 
						</div>
					</div>
					<div class="row form-group">
						<label for="walkin_email" class="col-sm-3 control-label">Email*</label>
						<div class="col-sm-6">
							<input type="email" class="form-control clear-saved" name="walkin_email" value="" id="walkin_email" required/> 
						</div>
					</div>
					<div class="row form-group">
						<label for="walkin_phone" class="col-sm-3 control-label">Phone*</label>
						<div class="col-sm-6">
							<input type="text" class="form-control clear-saved" name="walkin_phone" value="" id="walkin_phone" required/> 
						</div>
					</div>
					<div class="row form-group">
						<label for="walkin_notes" class="col-sm-3 control-label">Notes</label>
						<div class="col-sm-6">
							<textarea class="form-control clear-saved" name="walkin_notes" id="walkin_notes"></textarea>
						</div>
					</div>
					
					<div class="text-center">
						<button type="submit" class="btn btn-default">Submit form to head office</button>
					</div>
				</form>
			</div>
		</div>				

	
	
		
{else}
	{if $week}
		<div class="member-tab-content">
			暂无报名。
		</div>
	{/if}
{/if}

<script type="text/javascript">

	$(function() {	
		$('#SaveAttendance-form').validate(); 
		$('#WalkIn-form').validate(); 
	});

	function changeChkboxes(ID){
		if($(ID + ':checked').length > 0){
			$(ID).removeAttr("checked").trigger("change");
		}else{
			$(ID).attr("checked", "checked").trigger("change");
		}
	}
 	</script>
{/block} 


